package com.kedou.app;

import java.util.ArrayList;

import com.kedou.domain.ProjectItem;
import com.kedou.net.PostProjectList;
import com.kedou.net.PostUserWealth;
import com.kedou.util.NetworkUtil;
import com.kedou.util.PreferencesUtil;
import com.kedou.util.Util;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

/**
 * 我的财富 界面
 * 
 * @author zhouchao
 * 
 */
public class MyMoneyActivity extends BaseActivity {
	/**
	 * 中间 Title
	 */
	private TextView mTvTitle;
	/**
	 * 右侧 设置
	 */
	private ImageView mImgSetting;
	/**
	 * 我的项目估值
	 */
	private TextView mTvProjectValue;
	/**
	 * 累计总投入
	 */
	private TextView mTvTotalInvestment;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_mymoney);
		initView();
		setListener();
		getDataFromServer();
	}

	/**
	 * 从后台获取数据
	 */
	private void getDataFromServer() {
		mProgressDialog.show();
		if (NetworkUtil.isNetworkAvailable(MyMoneyActivity.this)) {
			new PostUserWealth(PreferencesUtil.getString(this, "token"),
					PreferencesUtil.getString(this, "userId"), Config.SOURCE,
					Util.getImei(this),
					new PostUserWealth.SuccessCallback() {

						@Override
						public void onSuccess(String msg,
								String projectValuation, String totalMoney) {
							mProgressDialog.dismiss();
							mTvProjectValue.setText(projectValuation);
							mTvTotalInvestment.setText(totalMoney);
						}
					}, new PostUserWealth.FailCallback() {

						@Override
						public void onFail(String msg) {
							mProgressDialog.dismiss();
							Toast.makeText(MyMoneyActivity.this, msg,
									Toast.LENGTH_SHORT).show();
						}
					}, MyMoneyActivity.this);
		} else {
			Toast.makeText(this,
					getResources().getString(R.string.check_your_network),
					Toast.LENGTH_SHORT).show();
		}

	}

	/**
	 * 初始化View
	 */
	private void initView() {
		mTvTitle = (TextView) findViewById(R.id.title);
		mTvTitle.setText(R.string.title_my_money);
		mImgSetting = (ImageView) findViewById(R.id.img_setting);
		mImgSetting.setVisibility(View.VISIBLE);
		mTvProjectValue = (TextView) findViewById(R.id.tv_my_project_value);
		mTvTotalInvestment = (TextView) findViewById(R.id.tv_total_investment);
	}

	/**
	 * 设置监听器
	 */
	private void setListener() {

	}
}
